package com.j01y.myhooks.Hooks;


import com.j01y.myhooks.Fake.FakeWifi;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

public class HookTestHandler {

    public static void wifi(final LoadPackageParam lpparam) {
        findAndHookMethod("android.net.wifi.WifiInfo", lpparam, "getMacAddress", FakeWifi.getMacAddress());
        findAndHookMethod("android.net.wifi.WifiInfo", lpparam, "getMacAddress", FakeWifi.getMacAddress());
    }


    public static void findAndHookMethod(String className, XC_LoadPackage.LoadPackageParam loadPackageParam, String methodName, final String result) {
        XposedHelpers.findAndHookMethod(className, loadPackageParam.classLoader, methodName, new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                super.afterHookedMethod(param);
                param.setResult(result);
            }
        });
    }


}
